//
//  HDWeixinHelper.h
//  leek-weixin_Example
//
//  Created by 吴非 on 2022/1/21.
//  Copyright © 2022 懒虫. All rights reserved.
//

#import <Foundation/Foundation.h>

// 加载协议
#import "HDWeixinAuthorizedLoginDelegate.h"
#import "HDWeixinPaymentDelegate.h"
#import "HDWeixinSharingDelegate.h"
#import "HDWeixinSmallRoutineDelegate.h"
#import "HDWeixinCustomerServiceDelegate.h"

// 加载模型
#import "HDPayOrderModel.h"

NS_ASSUME_NONNULL_BEGIN

// https://developers.weixin.qq.com/doc/oplatform/Mobile_App/Access_Guide/iOS.html
//WXSuccess           = 0,    /**< 成功    */
//WXErrCodeCommon     = -1,   /**< 普通错误类型    */
//WXErrCodeUserCancel = -2,   /**< 用户点击取消并返回    */
//WXErrCodeSentFail   = -3,   /**< 发送失败    */
//WXErrCodeAuthDeny   = -4,   /**< 授权失败    */
//WXErrCodeUnsupport  = -5,   /**< 微信不支持    */

// 支付宝通知状态
typedef NS_ENUM(NSInteger, HDWeixinResponseCode) {
    SUCCESS     = 0, // 订单支付成功
    FAILURE     = -1, // 普通错误类型
    CANCEL      = -2, // 用户点击取消并返回
    SentFail    = -3, // 发送失败
    AUTHDENY    = -4, // 授权失败
    UNSUPPORT   = -5, // 微信不支持
    JSONDATA    = 998, // 参数错误
    UNINSTALL   = 999, // 没安装微信
};

typedef void(^HDWeixinHelperCompletion)(NSInteger resultCode);

@interface HDWeixinHelper : NSObject

// 单例
+ (instancetype)defaultService;

/// 查看版本
- (NSString *)wxVersion;
/// 打印日志
- (void)wxLogger;

// MARK: - 参数配置
+ (void)rendering:(NSString*)appId universalLink:(NSString *)universalLink;

// MARK: - 授权登录
- (void)authorizedLogin:(NSString*)scope
               targetVC:(UIViewController*)tmpVC
         completeHandle:(id<HDWeixinAuthorizedLoginDelegate>)handle;

// MARK: - 快捷分享

/*分享图片*/
- (void)shareImageData:(NSData *)imageData
            ThumbImage:(UIImage *)thumbImage
               InScene:(NSInteger)scene
        completeHandle:(id<HDWeixinSharingDelegate>)handle;


/*分享链接*/
- (void)shareLinkURL:(NSString *)urlString
               Title:(NSString *)title
         Description:(NSString *)descr
          ThumbImage:(UIImage *)thumbImage
             InScene:(NSInteger)scene
      completeHandle:(id<HDWeixinSharingDelegate>)handle;

/*客服链接*/
- (void)contactCustomerServiceURL:(NSString *)urlString
                         corpCode:(NSString *)corpId
                   completeHandle:(id<HDWeixinCustomerServiceDelegate>)handle;

/*分享小程序*/
/**
 * 拉起的小程序的username
 * WXMiniProgramTypeRelease #  0是正式版，1是开发版，2是体验版
 * 拉起小程序页面的可带参路径，不填默认拉起小程序首页，如：传入 "?foo=bar"。
 */
-(void)shareLinkSmallRoutine:(NSString *)strUsername
                     pathURL:(NSString *)strPath
                 programType:(NSUInteger)miniProgramType
              completeHandle:(id<HDWeixinSmallRoutineDelegate>)handle;


// MARK: - 授权登录



// MARK: - 快捷支付

-(void)payWith:(HDPayOrderModel*)infor completeHandle:(id<HDWeixinPaymentDelegate>)handle;

// 发起支付集合版
-(void)payWithParameter:(NSString*)json completeHandle:(HDWeixinHelperCompletion)handleBlock;

// MARK: - 回调处理

- (BOOL)handleOpenURL:(NSURL *)openURL;

- (BOOL)handleUserActivity:(NSUserActivity *)userActivity;


@end

NS_ASSUME_NONNULL_END
